package cn.yunyichina.provider.framework.utils;

import java.text.SimpleDateFormat;
import java.util.Date;

public class ExceptionUtils {

    public static String getExceptionMessage(Throwable e) {
        String error = "";

        // 返回错误信息
        StackTraceElement[] elems = e.getStackTrace();
        String date = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date());
        StringBuffer sb = new StringBuffer();

        sb.append("错误堆栈：");
        sb.append(" " + e.getMessage() + "  ");
        for (int i = 0; i < elems.length; i++) {
            StackTraceElement elem = elems[i];
            sb.append("$$$$$" + elem.getClassName() + " Exception:" + e.getClass().getName() + " "
                    + elem.getMethodName() + "(" + elem.getLineNumber() + "行)#####  ");
        }
        error = sb.toString();
        return error;
    }
}
